<?php
$this->breadcrumbs = array(
	'Members'=>array('index'),
	'Create',
);

$this->menu = array(
	array('label'=>'Daftar Anggota', 'url'=>array('index')),
);
?>

<h1>Create Member</h1>

<div class="form">

	<?php
	$properties = array(
		'id'=>'member-form',
		'htmlOptions'=>array('enctype'=>'multipart/form-data'),
		'enableAjaxValidation'=>false,
	);
	$form = $this->beginWidget('CActiveForm', $properties);
	?>

	<p class="note">
		Fields with <span class="required">*</span> are required.
	</p>

	<?php
	$models = array_merge(array($image), array($model), $dates, $addresses);
	echo $form->errorSummary($models);
	?>

	<div class="row">
		<div class="row">
			<?php
			echo $form->hiddenField($image, "name");
			$id = CHtml::activeId($image, "file");
			echo CHtml::label($image->name, $id, array('required'=>true));
			echo $form->fileField($image, "file");
			echo $form->error($image, 'file');
			?>
		</div>
	</div>

	<div class="row">
		<?php
		echo $form->labelEx($model, 'name');
		$htmlOptions = array('size'=>60, 'maxlength'=>255, 'class'=>'fill');
		echo $form->textField($model, 'name', $htmlOptions);
		echo $form->error($model, 'name');
		?>
	</div>

	<div class="row">
		<?php
		echo $form->labelEx($model, 'callSign');
		echo $form->textField($model, 'callSign', $htmlOptions);
		echo $form->error($model, 'callSign');
		?>
	</div>

	<?php if (isset($_GET['type']) && $_GET['type']): ?>
		<div class="row">
			<?php
			echo $form->labelEx($model, 'code');
			echo $form->textField($model, 'code', $htmlOptions);
			echo $form->error($model, 'code');
			?>
		</div>
	<?php endif; ?>

	<div class="row">
		<?php
		echo $form->labelEx($model, 'reference');
		echo $form->textField($model, 'reference', $htmlOptions);
		echo $form->error($model, 'reference');
		?>
	</div>

	<div class="row">
		<?php
		echo $form->labelEx($model, 'gender');
		$properties = array(
			'model'=>$model,
			'attribute'=>'gender',
			'source'=>$model->genderList,
			'options'=>array(
				'minLength'=>'1',
			),
			'htmlOptions'=>$htmlOptions,
		);
		$this->widget('zii.widgets.jui.CJuiAutoComplete', $properties);
		echo $form->error($model, 'gender');
		?>
	</div>

	<div class="row">
		<?php
		echo $form->labelEx($model, 'birthPlace');
		echo $form->textField($model, 'birthPlace', $htmlOptions);
		echo $form->error($model, 'birthPlace');
		?>
	</div>

	<?php foreach ($dates as $key=>$value): ?>
		<div class="row">
			<?php
			echo $form->hiddenField($value, "[$key]name");
			$label = $value->name . ' (Tahun-Bulan-Tanggal)';
			echo CHtml::label($label, $id, array('required'=>true));
			/*
			$properties = array(
				'name'=>Chtml::activeName($value, "[$key]value"),
				'id'=>Chtml::activeId($value, "[$key]value"),
				'value'=>$value->value,
				'options'=>array(
					'showAnim'=>'fold',
					'dateFormat'=>'yy-mm-dd',
					'changeMonth'=>true,
					'changeYear'=>true,
					'showOtherMonth'=>true,
				),
			);
			$this->widget('zii.widgets.jui.CJuiDatePicker', $properties);
			*/
			echo $form->textField($value, "[$key]value", $htmlOptions);
			echo $form->error($value, "value");
			?>
		</div>
	<?php endforeach; ?>

	<fieldset>
		<legend>Telepon:</legend>
		<?php foreach ($phones as $key=>$value): ?>
			<div class="row">
				<?php
				$properties = array(
					'name'=>Chtml::activeName($value, "[$key]name"),
					'id'=>Chtml::activeId($value, "[$key]name"),
					'value'=>$value->name,
					'source'=>$value->nameList,
					'options'=>array(
						'minLength'=>'1',
					),
					'htmlOptions'=>$htmlOptions,
				);
				$this->widget('zii.widgets.jui.CJuiAutoComplete', $properties);
				echo $form->error($value, "name");
				echo $form->textField($value, "[$key]value", $htmlOptions);
				echo $form->error($value, "value");
				?>
			</div>
		<?php endforeach; ?>
	</fieldset>

	<?php foreach ($addresses as $key=>$value): ?>
		<fieldset>
			<?php echo $form->hiddenField($value,
					"[$key]name"); ?>
			<legend>Alamat <?php echo $value->name; ?>:</legend>
			<div class="row">
				<?php
				echo $form->labelEx($value, "[$key]street");
				echo $form->textField($value, "[$key]street", $htmlOptions);
				echo $form->error($value, "street");
				?>
			</div>
			<div class="row">
				<?php
				echo $form->labelEx($value, "[$key]city");
				echo $form->textField($value, "[$key]city", $htmlOptions);
				echo $form->error($value, "city");
				?>
			</div>
			<div class="row">
				<?php
				echo $form->labelEx($value, "[$key]province");
				echo $form->textField($value, "[$key]province", $htmlOptions);
				echo $form->error($value, "province");
				?>
			</div>
			<div class="row">
				<?php
				echo $form->labelEx($value, "[$key]postalCode");
				echo $form->textField($value, "[$key]postalCode", $htmlOptions);
				echo $form->error($value, "postalCode");
				?>
			</div>
		</fieldset>
	<?php endforeach; ?>

	<div class="row buttons">
		<?php
		$label = $model->isNewRecord ? 'Create' : 'Save';
		echo CHtml::submitButton($label);
		?>
	</div>

	<?php $this->endWidget(); ?>

</div><!-- form -->